package work;

import work.fram.JDBCConnect;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class ExistsJdbc {

    private static Statement statement = JDBCConnect.getStatement();

    private static List<String> all = new ArrayList<>();

    static {
        try {
            ResultSet resultSet = statement.executeQuery("SELECT name,idcard FROM tc_md_personnel");

            while (resultSet.next()) {

                String name = resultSet.getString("name");

                String idcard = resultSet.getString("idcard");

                String ni = name + "---" + idcard;

                all.add(ni);

            }

        } catch (SQLException e) {
            e.printStackTrace();
        }

    }

    public static boolean existByNameIdCard(String name, String idcard) {

        String ni = name + "---" + idcard;

        return all.contains(ni);

    }


    public static void main(String[] args) {
        System.out.println(existByNameIdCard("南迎宾", "610425198704180433"));
    }

}
